<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //   var a = 10;全局作用域，全局定义a
      //   console.log(a);
      //   function fn() {
      //     var a = 10;
      //     console.log(a);局部作用域在函数内部定义
      //   }
      //   fn();
      //   console.log(a);函数内部定义的变量只能函数内部定义
      function fn() {
        var a = 10;
        function fn1() {
          console.log(a);
        }
        fn1();
      }
      fn();
    </script>
  </body>
</html>
